import { ZBaseSettingManager } from '../Zcc'

/**
 * 设置,缓存起来
 */
export interface Setting {
	/** 骰子数量 */
	dice_num: number
	/** 骰子皮肤资源路径 */
	skin_dice: string
	/** 骰子摇晃器皮肤资源路径 */
	skin_shaker: string
	/** 摇晃音效资源路径 */
	sound_shake: string
	/** 筛盅预制体 */
	dice_prefab: string
}

export class SettingManager extends ZBaseSettingManager<Setting> {
	private static _instance: SettingManager = null

	// 设置缓存键名
	protected readonly SETTINGS_CACHE_KEY = '_game_settings_'

	// 默认设置资源路径
	protected readonly DEFAULT_SETTINGS_PATH = 'data/settings'

	// 指定需要持久化的属性
	protected readonly PERSISTENT_KEYS: (keyof Setting)[] = ['dice_num', 'skin_dice', 'skin_shaker', 'sound_shake']

	/**
	 * 获取单例实例
	 */
	public static get instance(): SettingManager {
		if (!this._instance) {
			this._instance = new SettingManager()
		}
		return this._instance
	}
}
